# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Alexander Monakov <amonakov@gmail.com>

pkgname=primus
pkgver=20151110
pkgrel=9
pkgdesc="Faster OpenGL offloading for Bumblebee"
arch=('loong64' 'x86_64')
url="https://github.com/amonakov/primus"
license=('custom:ISC')
depends=('bumblebee')
makedepends=('git')
_commit=d1afbf6fce2778c0751eddf19db9882e04f18bfd  # master
source=("git+https://github.com/amonakov/primus#commit=$_commit"
        "register_cleanup.patch")
sha1sums=('SKIP'
          'fd48f89c55c1ad854d7a985781faed2c52c0135f')

prepare() {
  cd primus
  patch -Np1 -i ../register_cleanup.patch
}

build() {
  cd primus
  make
}

package() {
  cd primus

  sed -e '/^PRIMUS_libGL=/cPRIMUS_libGL=/usr/\\$LIB/primus' \
      -e '/^exec/iexport __GLVND_DISALLOW_PATCHING=1' \
    primusrun | install -D /dev/stdin "$pkgdir/usr/bin/primusrun"

  install -D lib/libGL.so.1 "$pkgdir/usr/lib/primus/libGL.so.1"
  install -D primus.bash-completion "$pkgdir/usr/share/bash-completion/completions/primusrun"
  install -D primusrun.1 "$pkgdir/usr/share/man/man1/primusrun.1"
  install -D -m644 LICENSE.txt "$pkgdir/usr/share/licenses/primus/LICENSE"
}

# vim:set ts=2 sw=2 et:
